<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="申请人昵称:" prop="nickname">
        <el-input
          style="width: 300px"
          v-model="queryParams.nickname"
          placeholder="请输入申请人微信昵称或用户id"
          clearable
          @keyup.enter.native="handleQuery">
          <el-button circle slot="append" icon="el-icon-search" @click="handleQuery"></el-button>
        </el-input>
      </el-form-item>
      <el-form-item label="提现状态:" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择" clearable @change="handleQuery">
          <el-option
            v-for="dict in dict.type.withdraw_state"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="微信信息">
        <template slot-scope="scope">
          <div class="wxInfoTitle">
            <image-preview class="wxInfoImg" :src="scope.row.avatarUrl" :width="50" :height="50"/>
            <router-link :to="'/member/info/index/' + scope.row.memberId" class="link-type link-text">
              <el-tooltip placement="top">
                <div slot="content">
                  用户昵称：{{ scope.row.nickname }}
                  <br/>
                  用户id：{{ scope.row.wxUserId }}
                </div>
                <div class="wxInfo">
                  <div class="wxInfoItem">用户昵称：{{ scope.row.nickname }}</div>
                  <div class="wxInfoItem">用户id：{{ scope.row.wxUserId }}</div>
                </div>
              </el-tooltip>
            </router-link>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="状态" key="state" prop="state">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.withdraw_state" :value="scope.row.state"/>
        </template>
      </el-table-column>
      <el-table-column label="申请提现金额" key="amount" prop="amount">
        <template slot-scope="scope">
          {{ scope.row.amount }} 元
        </template>
      </el-table-column>
      <el-table-column label="客户可提现金额" key="walletAmount" prop="walletAmount">
        <template slot-scope="scope">
          {{ scope.row.walletAmount }} 元
        </template>
      </el-table-column>
      <el-table-column label="申请时间" prop="createTime">
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="驳回理由" prop="remark"/>
      <el-table-column label="审核时间" prop="auditTime">
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.auditTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" class-name="small-padding fixed-width" align="center" width="200">
        <template slot-scope="scope">
          <el-button v-if="scope.row.state == 1" type="text" @click="agree(scope.row.id)">同意申请</el-button>
          <el-button v-if="scope.row.state == 1" type="text" @click="reject(scope.row.id)">驳回申请</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { memberWithdrawPageList } from "@/api/triones/orderTrade";
export default {
  name: "index",
  dicts: ['withdraw_state'],
  data() {
    return {
      loading: true,
      showSearch: true,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        nickname: undefined,
        state: undefined
      },
      dataList: [],
      total: 0
    }
  },
  created() {
    this.getDataList();
  },
  methods: {
    /** 获取申请列表 */
    getDataList() {
      memberWithdrawPageList(this.queryParams).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    /** 检索 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getDataList();
    },
    /** 同意申请 */
    agree(id) {
      this.$message.warning("暂不可操作，支付正在升级完善");
    },
    /** 拒绝申请 */
    reject(id) {
      this.$message.warning("暂不可操作，支付正在升级完善");
    }
  }
}
</script>

<style lang="scss" scoped>

.wxInfoTitle{
  display:flex;
  width: 100%;
  height: 100%;
  .wxInfoImg {
    vertical-align: middle;
  }
}

.wxInfo {
  display: inline-block;
  padding-left: 8px;
  text-align: left;
  align-content: center;
  vertical-align: middle;
  .wxInfoItem {
    padding: 3px 0;
    font-size: 12px;
    line-height: 12px;
  }
}

.link-text {
  align-content: center;
}
</style>
